package ws.jdbc.concurrent.driver.sqlserver.tds.datatypes;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class BYTELEN extends TYPE_VARLEN {

  //private static final int byteSize = 1;

  BYTELEN(int length) {
    super(length, 1);
  }

  @Override
  public byte[] getBytes() {
    return new byte[]{(byte) length};
  }

  @Override
  public int size() {
    return size;
  }

  @Override
  public TYPE_VARLEN read(final ByteBuffer is) throws IOException {
    length = is.get();
    return this;
  }

  @Override
  public boolean wasNull() {
    return (byte) length == GeneralRules.GEN_NULL;
  }
}
